from google.appengine.ext import db
import re

class Article(db.Model):

    author = db.UserProperty()
    authornickname = db.StringProperty()
    title = db.StringProperty()
    content = db.TextProperty()
    summary = db.StringProperty()
    imagelink = db.LinkProperty()
    date = db.DateTimeProperty(auto_now_add=True)
    categories = db.StringListProperty()
    type = db.StringProperty()
    published = db.BooleanProperty(False)
    mainfeature = db.BooleanProperty(False)
    commentcount = db.IntegerProperty(default=0)
    titleurlpath = db.StringProperty()

    def getKey(self):
        return self.key()

    def isValid(self):
        return True

    def setTitleUrlPath(self):
        if (self.title):
            realpha = re.compile('[\W]')
            self.titleurlpath = realpha.sub('_', self.title)
    


    


    
